package com.china08.yxyapi.api.home.activity.marker;

import java.text.ParseException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.model.YxyApiReqModel;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.repository.db.marker.YxyMakerWorksRepository;

/**
 * 区域教育局-竞赛报名-创建
 * 
 */
@CrossOrigin
@RestController
public class YxyMakerWorksDelController extends YxyApiBaseController {

    @Autowired
    private YxyMakerWorksRepository yxyMakerWorksRepository;

    @ResponseBody
    @RequestMapping(value = "/api_yw/home/activity/competition/catalog/works/del", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel precess(HttpServletRequest request, HttpServletResponse response, @RequestBody ReqModel reqModel)
            throws ParseException {
        RespModel respModel = new RespModel();
        try {
            yxyMakerWorksRepository.delete(reqModel.id);
            respModel.notice = 1;
        } catch (Exception e) {
            e.printStackTrace();
            respModel.notice = 2;
        }
        return respModel;
    }

    public static class ReqModel extends YxyApiReqModel {
        // id
        public String id;
    }

    protected static class RespModel extends YxyApiRespModel {
        // 1：成功 2：失败
        public Integer notice;
    }

}
